package org.karelun.rabbit.bridge.ui.action;

import java.util.Collection;

import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.edit.command.CopyToClipboardCommand;
import org.eclipse.ui.IWorkbenchPart;
import org.karelun.rabbit.bridge.ITransactionEditingDomain;
import org.karelun.rabbit.bridge.ITransactionEditingDomainProvider;

public class RabbitCopyAction extends RabbitCommandActionHandler{

	public RabbitCopyAction(ITransactionEditingDomain domain) {
		super(domain,"Copy");
	}
	
	public RabbitCopyAction(){
		super(null,"Copy");
	}
	
	@Override
	protected Command createCommand(Collection<Object> collection) {
		return CopyToClipboardCommand.create(editingDomain, collection);
	}
	
	public void setActiveWorkbenchPart(IWorkbenchPart workbenchPart){
		if(workbenchPart instanceof ITransactionEditingDomainProvider){
			editingDomain=((ITransactionEditingDomainProvider)workbenchPart).getTransactionEditingDomain();
		}
	}
}
